Python project template - mypy
using mypy
install#
pip install mypy
demo#
demo.py
def func(a, b):
return a+b
usage#
from cli#
shell
mypy demo.py
Success: no issues found in 1 source file
## Strict mode
mypy --strict demo.py
error: Function is missing a type annotation
Found 1 error in 1 file (checked 1 source file)
VSCode#
- Enabled mypy
- Set
strictargument
settings.json
"python.linting.mypyEnabled": true
config#
pyproject.toml
[tool.mypy]
strict = true
